﻿using ChurchDiary.BLL;
using ChurchDiary.Common;
using ChurchDiary.TableEntity;
using ChurchWebsite.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ChurchWebsite.Areas.Settings.Controllers
{
    public class UserSettingsController : BaseController
    {
        //
        // GET: /Settings/UserSettings/
        public ActionResult Index()
        {
            ViewBag.Name = Current.Name;
            ViewBag.LastLogin = Current.LastLogin;
            return View();
        }
        public JsonResult GetUserSettings()
        {
            return Json(new BLL_Login().GetUserSettings(Current.Userid),JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetCountry()
        {
            return Json(new BLL_Shared().GetCountryList(),JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetStates(Guid CountryId)
        {
            return Json(new BLL_Common().GetStateList(CountryId), JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetLanguages()
        {
            return Json(new BLL_Shared().GetLanguages(), JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetDateformat()
        {
            return Json(new BLL_Shared().GetDateformat(), JsonRequestBehavior.AllowGet);
        }
        public JsonResult SaveDefaultSettings(EntityUserSettings Settings)
        {
            return Json(new BLL_Login().UpdateUserSettings(Settings), JsonRequestBehavior.AllowGet);
        }
        public JsonResult ChangePassword(EntityChangePassword ChangePassword)
        {
            return Json(new BLL_Settings().ChangePassword(ChangePassword.OldPassword,ChangePassword.NewPassword,Current.Userid));
        }
    }
}
